<?php

Raise::load('core.collection.RaiseIterator');

/**
 * TestCoreRaiseIterator class
 * Testing unit of 'phpraise/core/RaiseIterator.php'
 *
 * @author Sam-Mauris Yong / hellclanner at live dot com
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package Raise.UnitTest.Test
 */
class TestCoreRaiseIterator extends RaiseTest {

    public static function testClass(){
        self::assertClassExists('RaiseIterator');
        self::assertClassExtends('RaiseIterator', 'RaiseObject');

        $test = array(34, 241, 541, 1234, 523, 23, 231, 'test' => '1231');
        
        $iterator = new RaiseIterator($test);
        while ($a = $iterator->iterate()){
            self::assertType($a, 'object');
            self::assertObjectClass($a, 'RaiseKeyValuePair');
            self::assertTrue(in_array($a->value(), $test));
            self::assertTrue(array_key_exists($a->key(), $test));
        }

        $iterator->reset();
        $i = 0;
        while($iterator->more()){
            $c = $iterator->current();
            $i++;
            $a = $iterator->next();
        }
        self::assertStrictEqual($i, $iterator->count());
    }

}

